#include <stdio.h>
#include <dlfcn.h>

int main (int argc, char **argv)
{
	//函数指针
	typedef int (*math_t) (int , int);
#if 0
	for (int i = 0; i < argc; i++) {
		printf ("argv[%d] == %s\n", i, *(argv + i));
	}
#endif
	void *handle = NULL;
	handle = dlopen (argv[1], RTLD_NOW);
	if (handle == NULL) {
		printf ("open %s failed!\n", argv[1]);
		return -1;
	}

	printf ("dlopen success...\n");

	void *f = dlsym (handle, "e_add");
	if (NULL == f) {
		printf ("%s", dlerror());
	}
	math_t p = (math_t)f;
	printf ("%d\n", p (16, 9));
	if (dlclose (handle)) {
		printf ("dlclose failed!\n");
	}
	return  0;
}
